﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
///JobApply 的摘要说明
/// </summary>
public class JobApply
{
    private SqlCommand cmd;
    private SqlTransaction tran;
	public JobApply()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    public string jobapply(TBjobapply tbja)
    {
       string result = "0";
       try
       {
           cmd = new SqlCommand();
           cmd.Connection = ConDB.GetOpen();
           //tran = cmd.Connection.BeginTransaction();
           //cmd.Transaction = tran;
           cmd.CommandText="insert tb_jobapply values(@pid,@cwid,getdate(),@islook)";
           cmd.Parameters.Add("@pid", SqlDbType.VarChar, 20).Value = tbja.Pid;
           cmd.Parameters.Add("@cwid", SqlDbType.Int).Value = tbja.Cwid;
           cmd.Parameters.Add("@islook", SqlDbType.Bit).Value = tbja.Islook;
           int i = cmd.ExecuteNonQuery();
           if (i > 0)
           {
               result = "1";
               //tran.Commit();
           }         
       }
       catch (Exception e)
       {
           result = "0";
           //tran.Rollback();
       }
       finally {
           ConDB.Close();
       }
       return result;
    }
    public string isapply(TBjobapply tbja)
    {
        string result = "0";
        try
        {
            cmd = new SqlCommand();
            cmd.Connection = ConDB.GetOpen();
            //tran = cmd.Connection.BeginTransaction();
            cmd.CommandText = "select count(*) from tb_jobapply where pid=@pid and cwid=@cwid";
            cmd.Parameters.Add("@pid", SqlDbType.VarChar, 20).Value = tbja.Pid;
            cmd.Parameters.Add("@cwid", SqlDbType.Int).Value = tbja.Cwid;
            int i =Convert.ToInt32(cmd.ExecuteScalar());
            if (i > 0)
            {
                result = "1";
                //tran.Commit();
            }
        }
        catch (Exception e)
        {
            result = "0";
            //tran.Rollback();
        }
        finally
        {
            ConDB.Close();
        }
        return result;
    }
}
